//Neal Whitworth
//Class: Class.cpp
//This is the .cpp file for the class object
//Coded by Neal Whitworth
//Random branch test


#include "Class.h"  

using namespace std;
using namespace ClassNamespace;

#include <string>  
#include <iostream>  

//The constructor that sets everything there is for a class  
Class::Class(string department, int courseNumber, int section, string days, int start, int end, string building, int room, string instructor, bool crossListed, bool teamTaught){
	Set( department,  courseNumber,  section,  days,  start,  end,  building,  room,  instructor, crossListed, teamTaught);
}

//the private setter which all public methods that need to set something will call  
void Class::Set(string department, int courseNumber, int section, string days, int start, int end, string building, int room, string instructor, bool crossListed, bool teamTaught){
	this->instructor = instructor;
	this->start = start;
	this->end = end;
	this->department = department;
	this->section = section;
	this->room = room;
	this->building = building;
	this->courseNumber = courseNumber;
	this->days = days;
	this->crossListed = crossListed;
	this->teamTaught = teamTaught;
}

string Class::getInstructor(){
	return this->instructor;
}

int Class::getStart(){
	return this->start;
}

int Class::getEnd(){
	return this->end;
}

string Class::getDepartment(){
	return this->department;
}

int Class::getSection(){
	return this->section;
}

int Class::getRoom(){
	return this->room;
}

string Class::getBuilding(){
	return this->building;
}

int Class::getCourseNumber(){
	return this->courseNumber;
}

string Class::getDays(){
	return this->days;
}

bool Class::getCrossListed(){
	return this->crossListed;
}
	
bool Class::getTeamTaught(){
	return this->teamTaught;
}

void Class::setInstructor(string i){
	Set(i, this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setStart(int s){
	Set(this->getInstructor(), s, this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setEnd(int e){
	Set(this->getInstructor(), this->getStart(), e, this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setDepartment(string d){
	Set(this->getInstructor(), this->getStart(), this->getEnd(), d, this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setSection(int s){
	Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), s, this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setRoom(int r){
	Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), r,
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setBuilding(string b){
	Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		b, this->getCourseNumber(), this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setCourseNumber(int c){
	Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), c, this->getDays(), this->getCrossListed(), this->getTeamTaught());
}

void Class::setDays(string d){
	Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), d, this->getCrossListed(), this->getTeamTaught());
}

void Class::setCrossListed(){
	if (crossListed){
		Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
			this->getBuilding(), this->getCourseNumber(), this->getDays(), false, this->getTeamTaught());
	}
	else {
		Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
			this->getBuilding(), this->getCourseNumber(), this->getDays(), true, this->getTeamTaught());
	}
}

void Class::setTeamTaught(){
	if (teamTaught){
		Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), false);
	}
	else {
		Set(this->getInstructor(), this->getStart(), this->getEnd(), this->getDepartment(), this->getSection(), this->getRoom(),
		this->getBuilding(), this->getCourseNumber(), this->getDays(), this->getCrossListed(), true);
	}
}

string Class::IntegerToString(int x){
	string s = std::to_string(x);
	return s;
}

bool Class::Overlaps(Class *c){
	//first check times, then check room numbers 
	if (this->getStart() == c->getStart()){
		return true;
	}
	else if (this->getEnd() == c->getEnd()){
		return true;
	}
	else{
		return false;
	}
}

//returns a formatted string of all data values in class objects
string Class::toString(){
	return "Department = " + Class::getDepartment() +
		"\n  Course Number = " + Class::IntegerToString(Class::getCourseNumber()) +
		"\n  Section = " + Class::IntegerToString(Class::getSection()) +
		"\n  Days = " + Class::getDays() +
		"\n  Start Time = " + Class::IntegerToString(Class::getStart()) +
		"\n  End Time = " + Class::IntegerToString(Class::getEnd()) +
		"\n  Building = " + Class::getBuilding() +
		"\n  Room = " + Class::IntegerToString(Class::getRoom()) +
		"\n  Instructor = " + Class::getInstructor();
		
}
